package com.damie.controller;


import com.dadie.Domain.WasteDomain;
import com.dadie.Dto.WasteDto;
import com.dadie.parame.WasteParame;
import com.dadie.parame.WasteParameUpdate;
import com.damie.common.commonutils.R;
import com.damie.service.WasteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alon
 * @since 2021-01-22
 */
@Api(value="站点controller",tags={"后台:分类管理"})
@RestController
@CrossOrigin("*")
@RequestMapping("/damie/waste")
public class WasteController {

    @Resource
    private WasteService service;

    @ApiOperation("指定id站点子父级分类的添加")
    @PostMapping("siteAddTypeBySiteId")
    public R siteAddTypeBysiteId(String site, @RequestBody WasteParame wasteParame){
        WasteDto wasteDto = service.siteAddTypeBysiteId(site, wasteParame);
        return R.ok().data("suceess",wasteDto);
    }

    @ApiOperation("某个站点提交的分类修改")
    @PutMapping("updateTypeBySiteId")
    public R TypeBySiteId(String site,@RequestBody WasteParameUpdate wasteParame){
        WasteDto wasteDto = service.updateTypeBySiteId(site,wasteParame);
        return R.ok().data("sucess",wasteDto);
    }

    @ApiOperation("删除某个站点的分类")
    @DeleteMapping("deleteTypeBySiteId")
    public R deleteTypeBySiteId(String site,String wasteId){
        WasteDto wasteDto = service.deleteTypeBySiteId(site,wasteId);
        return R.ok().data("sucess",wasteDto);
    }

    @ApiOperation("查询某个站点的所有一级分类")
    @GetMapping("selectTypeBySiteId1")
    public R selectTypeBySiteId1(String site){
        List<WasteDto> wasteDtos = service.selectTypeBySiteId(site);
        return R.ok().data("wasteList", wasteDtos);
    }

    @ApiOperation("查询某个站点的所有二级分类")
    @GetMapping("selectTypeBySiteId2")
    public R selectTypeBySiteId2(String site,String parentId){
        List<WasteDto> wasteDtos = service.selectTypeBySiteId2(site,parentId);
        return R.ok().data("wasteList", wasteDtos);
    }


}

